package com.ayjsolutions.marcadoresfutbol;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import com.ayjsolutions.marcadoresfutbol.util.Utiles;

public class StartActivity extends Activity {

	public static List<PartidoLista> partidos = new ArrayList<PartidoLista>();
	Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		context = this;

		new LoadViewTask().execute();

	}

	private class LoadViewTask extends AsyncTask<Void, Integer, Void> {

		// Before running code in separate thread
		@Override
		protected void onPreExecute() {
			setContentView(R.layout.start_layout);
		}

		// The code to be executed in a background thread.
		@Override
		protected Void doInBackground(Void... params) {
			partidos = Utiles.startDatabaseSession(context, 1);
			return null;
		}

		// Update the progress
		@Override
		protected void onProgressUpdate(Integer... values) {

		}

		// after executing the code in the thread
		@Override
		protected void onPostExecute(Void result) {
			Intent intent = new Intent(StartActivity.this, MainActivity.class);
			startActivityForResult(intent, 0);
		}

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		Log.w("Back", "Leaving... see you next time!");
		finish();
	}

}
